package mcommand;

/**
 * Holds a highscore unit with playername and score.
 *
 * @author Marcel, Christian, Klaus
 */
public class HighscoreUnit implements Comparable<HighscoreUnit> {
    // defines a variable for the player name
    public String playername;

    // defines a variable for the score
    public int score;

    /**
     * Sets the variable score to the parameter score. Sets the variable
     * playername to the parameter playername.
     * 
     * @param playername playername
     * @param score score
     */
    public HighscoreUnit(final String playername, final int score) {
        this.playername = playername;
        this.score = score;
    }

    /**
     * Can compare the score with a highscore unit.
     * 
     * @param unit unit
     * @return 1, 0, -1
     */
    public final int compareTo(final HighscoreUnit unit) {
        if (score < unit.score) {
            return 1;
        } else if (score == unit.score) {
            return 0;
        } else {
            return -1;
        }
    }
}
